package com.example.aerospacemanagementsystem.controller.basic;

import com.example.aerospacemanagementsystem.entity.basic.Department;
import com.example.aerospacemanagementsystem.service.basicService.DepartmentService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 铁殷
 */

@Api(tags = "部门")
@RestController
@CrossOrigin
@RequestMapping("/department")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;
    //添加部门
    @PostMapping
    public int add(@RequestBody Department department){
        return departmentService.add(department);
    }
    //删除部门
    @DeleteMapping
    public int delete(Department department){
        return departmentService.delete(department);
    }
    //修改部门
    @PutMapping
    public int update(@RequestBody Department department){
        return departmentService.update(department);
    }
    //获取部门
    @GetMapping("/getAll")
    public List<Department> getAllCity(Department department) {
        List<Department> list = departmentService.getAllDepartment(department);
        return list;
    }
}
